<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>setup</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
    <div id="root"></div>
    <script>
        const handleListValue=()=>{
            const {reactive}=Vue
            const list=reactive([])
            handleClick=(item)=>{
                    list.push(item)           
                }
                return{list,handleClick}
        }
        const handleInput=()=>{
            const {ref}=Vue
            let inputValue=ref('');
            handleInputValue=(el)=>{
                    inputValue.value=el.target.value
                }
                return{inputValue,handleInputValue}
        }
        const app=Vue.createApp({
            setup(){
                const {inputValue,handleInputValue}=handleInput()
                const {list,handleClick}=handleListValue()
                return {inputValue,handleInputValue,handleClick,list}
            },
            template:'<div><input :value="inputValue" @input="handleInputValue"/><button @click="handleClick(inputValue)">提交</button></div><ul><li v-for="(item,index) in list" key="index">{{item}}</li></ul>'
        })
        app.mount('#root')
    </script>
</body>
</html>